import 'package:json_annotation/json_annotation.dart';

part 'xmm_app_config.g.dart';

@JsonSerializable()
class XmmAppConfig {
  String? rvsta;
  String? ver;
  List<Map<String, dynamic>>? items;
  XmmRiskControlInfoConfig? riskControlInfoConfig;

  XmmAppConfig(this.rvsta, this.ver, this.items, this.riskControlInfoConfig);

  factory XmmAppConfig.fromJson(Map<String, dynamic> json) =>
      _$XmmAppConfigFromJson(json);

  Map<String, dynamic> toJson() => _$XmmAppConfigToJson(this);

  String? getRCAppKey(){
    return items?.firstWhere((element) => element['name'] == 'rck')['data'];
  }

  String? getTranslationKey(){
    return items?.firstWhere((element) => element['name'] == 'google_translation_key')['data'];
  }
}

@JsonSerializable()
class XmmRiskControlInfoConfig {
  int? k_interval;
  String? k_factor;
  String? k_factor_num;

  XmmRiskControlInfoConfig(this.k_interval, this.k_factor, this.k_factor_num);

  factory XmmRiskControlInfoConfig.fromJson(Map<String, dynamic> json) =>
      _$XmmRiskControlInfoConfigFromJson(json);

  Map<String, dynamic> toJson() => _$XmmRiskControlInfoConfigToJson(this);
}
